# FindFreeImage.cmake
# This file will be used by find_package(FreeImage) to find the FreeImage-Library in CMake Projects
#
# Variables that will be set:
# - FREEIMAGE_FOUND			Whether FREEIMAGE could be found
# - FREEIMAGE_INCLUDE_DIR	The FREEIMAGE Include-Directory
# - FREEIMAGE_LIBRARIES		The FREEIMAGE-Libraries you need to link


#Include
find_path(FREEIMAGE_INCLUDE_DIR FreeImage.h
	PATH_SUFFIXES FreeImage/include include Dist Dist/x32 Dist/x64 x32 x64
	NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH
)


# Library
find_library(FREEIMAGE_DEBUG NAMES FreeImageLibd FreeImaged
	PATH_SUFFIXES Dist/x32 Dist/x64 x32 x64
	NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
find_library(FREEIMAGE_RELEASE NAMES FreeImageLib FreeImage
	PATH_SUFFIXES Dist/x32 Dist/x64 x32 x64
	NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
			
SET(FREEIMAGE_LIBRARIES "optimized;${FREEIMAGE_RELEASE};debug;${FREEIMAGE_DEBUG}" CACHE STRING "The FreeImage-Libraries")


# FREEIMAGE_FOUND and other stuff
INCLUDE(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
	FreeImage DEFAULT_MSG
	FREEIMAGE_INCLUDE_DIR FREEIMAGE_DEBUG FREEIMAGE_RELEASE
)
mark_as_advanced(FREEIMAGE_DEBUG FREEIMAGE_RELEASE)